<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link rel="stylesheet" type="text/css" href="html/res/css/style.css" />
<title>学校</title>
<style type="text/css">
.cp-hand{
cursor:pointer;
}
.zcelist0{ width:562px; color:#595959; font-size:12px; height:36px; border:0px solid #ebebeb; padding-left:436px; margin-bottom:33px;}
</style>
</head>
<body>
<!-- $headnav$ -->
<div id="zhuce">
	<div class="zcelist"><b class="bzce">欢迎登录</b></div>

	<div id="div_errormsg" class="zcelist0 hide"><b class="bzce"><span id="errormsg" style="color:#f00;"></span></b></div>
	
    <div class="zcekk">    
    
    	<form id="login" action="mis.php?c=guest&a=login" method="post">
    		<ul>
            	<li class="zcekkb"><span class="denglusp">登录名：</span>
                <!-- <input type="text"  class="zcekksr2"/> -->
                <input placeholder="邮箱" id="email"  value="" type="text" class="zcekksr2">
                </li>
                <li class="zcekkb"><span class="denglusp">密　码：</span>
                <!-- <input type="text"  class="zcekksr2"/> -->
                <input placeholder="密码" id="password"  value="" type="password" class="zcekksr2">
                </li>
                <li class="denglubj"><span class="denglusp denglubj1">数字码：</span>
					<span class="denglusp1">
						<!-- <input name="" type="text"  class="denglukk"/> -->
						<input type="text" name="validate" value="" size=10 class="denglukk"> 
					</span>					
					<!-- <a href="#"><img src="html/res/images/shuzi_03.jpg" width="102" height="47"  class="left"/></a> -->
					<img width="102" height="47"  class="left cp-hand" title="点击刷新" src="./php/lib/captcha/captcha.php" align="absbottom" onclick="this.src='php/lib/captcha/captcha.php?'+Math.random();"></img>
				</li>
                <li class="zceyh"><a href="#"><img src="html/res/images/zuc6_13.jpg" width="14" height="14" class="zcekkimg2"/></a>记住信息				                 <span><a href="#" class="dluwj">忘记密码？</a></span></li>
                <li class="zcekkb1">
    	            <a href="javascript:login()" id="submitbtn" class="zcesa1">登录</a>
					<button type="submit" class="hide"></button>
                </li>
            </ul>
	</form>
    </div>
    <div class="dengludb">
    	<span class="dengludbs">还没有账户</span>
        <span><a href="?a=zhuce" class="dengludbsa">免费注册</a></span>
    </div>
</div>

<script src="html/res/jquery-1.8.1.min.js"></script>
<script src="html/res/app.js?v=100"></script>
<script>
'use strict';
$(document).ready(function() { 

	$("submitbtn").click(function(){
	  login();
	});

}); 


function login() {
    var name = $("#email").val();
    var pwd = $("#password").val();
    var savename = $("#save_name").val();

    if (name.length<1) {
        errMsg('账号不能为空', '2000');
        return;
    } else if (pwd.length<1) {
        errMsg('密码不能为空', '2000');
        return;
    }

    waitWin();
    var api_root=get_server_root();
    var url = api_root+'/apps/survival_camp_v1/index.php?c=guest&a=login2';
    var api = api_root+'/apps/survival_camp_v1/index.php?c=api';

    url = url + '&email='+Url.encode(name);
    url = url + '&password='+Url.encode(pwd);

    // if(ls_v('debug_mode')=='1') 
    alert(url);
    
    AJAX.get(url,function(res){
        autoClsMsg(res,2500);
        // alert(res); 
        if(res.length<3){
            alert('异常的返回值！'+res);
            return false;
        }
        var jj=str2json(res);
        if(jj.alert){
            alert(jj.alert);
        }
        if(jj && jj.token && jj.message){
            autoClsMsg(jj.message+' token='+jj.token+' '+res,2500);
            // alert(jj.message);
            // alert('../sc_camp/camp.html?token='+jj.token);
            if(jj && jj.token){

                if (savename.length>1) {
                    ls_set('user_name',name);
                    ls_set('user_pwd',pwd);
                }
                
                autoClsMsg(jj.message+' save token to local ! '+res,2500);

   
                var pc_url = api + '&a=player_info&token='+jj.token+'&uid='+jj.uid;
                // if(ls_v('debug_mode')=='1') alert(pc_url);

                AJAX.get(pc_url,function(res2){
                    if(res2.length<3){
                        alert('异常的返回值！#2');
                        return false;
                    }

                    autoClsMsg('Get Exp by Token ! '+res2,3500);
                    // alert(res2);
                    var tt=str2json(res2);
                    if(tt && tt.err_code=='0'){
                        if(tt.alert) alert(tt.alert);
                        autoClsMsg('Get Exp by Token OK! '+res2,3500);
                        var ttd = tt.data;
           
                        winCls();

                    }else{
                        if(tt.message){
                            alert(tt.message);
                        }else{
                            alert('Error! ' +res2);
                        }                                
                    }
                },function(){
                    alert('登陆失败！请检查网络是否畅通！#pc_info');
                    alert(pc_url);
                });

            }
        }else{
            if( jj.message){
                alert( jj.message);
            }else{
                alert('Error! ' +res);
            }
        }
    },function(){
        alert('登陆失败！请检查网络是否畅通！#login');  
        alert(url);
    });

}


</script>
<!-- $foot$ -->
</body>
</html>